<template>
	<view class="container">
		<view class="myorder_no" v-if="rows.length==0">暂无相关信息</view>
		<view class="list">
			<block v-for="(item,index) in rows" :key="item.id">

				<view class="pro_dl">
					<view class="pro_dt" @click="url" :data-id="item.pid">
						<image :src="item.image" mode="aspectFill"></image>
					</view>
					<view class="pro_dd">
						<view class="pro_title">{{item.name}}</view>
						<view class="pro_lable">{{item.cate}}</view>
						<view class="pro_bottom">
							<view class="pro_price">￥{{item.price}}</view>
							<view class="pro_num" @click="del" :data-id="item.id">
								<view class="iconfont icon-shoucang1"></view>
							</view>
						</view>
					</view>
				</view>

			</block>


		</view>
	</view>
</template>

<script>
	import API from "@/common/api.js";
	export default {
		data() {
			return {
				rows: []
			}
		},
		onLoad() {
			this.search()
		},
		methods: {
			url(e) {
				var id = e.currentTarget.dataset.id;
				uni.redirectTo({
					url: "/pages/goodsdetail/goodsdetail?id=" + id
				})
			},
			search() {
				var $this = this
				API.post("product/myBookmark").then((res) => {
					if (res.code == 1) {
						$this.rows = res.data
					}
				})
			},
			del(e) {
				var id = e.currentTarget.dataset.id;
				var $this = this
				API.post("product/bookmarkdel", {
					id: id
				}).then((res) => {
					if (res.code == 1) {
						$this.search()
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: #f7f7f7;
	}

	.list {
		padding: 30rpx;
		overflow: hidden;
	}

	.pro_dl {
		width: 100%;
		overflow: hidden;
		margin-bottom: 30rpx;
		background: #fff;
		border-radius: 20rpx;
		padding: 30rpx;
		box-sizing: border-box;
	}

	.pro_dt {
		width: 180rpx;
		height: 180rpx;
		border-radius: 10rpx;
		overflow: hidden;
		display: flex;
		justify-content: center;
		align-items: Center;
		float: left;
	}

	.pro_dt image {
		width: 100%;
		height: 100%;
		border-radius: 10rpx;
	}

	.pro_dd {
		padding-left: 210rpx;
	}

	.pro_title {
		line-height: 44rpx;
		font-size: 28rpx;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.pro_lable {
		color: #999;
		margin-top: 10rpx;
	}

	.pro_bottom {
		margin-top: 50rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.pro_price {
		font-size: 28rpx;
	}

	.pro_num {
		color: $color;
	}

	.myorder_no {
		width: 100%;
		overflow: hidden;
		margin-top: 150rpx;
		text-align: center;
		color: #999;
	}
</style>